package com.dg.gaming.client.gui {
    import com.dg.gaming.api.common.GameModel;

    import flash.events.Event;

    import mx.containers.Canvas;

    public class MainPanel extends Canvas {

        GameImages.getInstance();

        public static var mainpanel:MainPanel;

        private var mainGamePanel:MainGamePanel;

        private var _gameModel:GameModel;

        public function get gameModel():GameModel {
            return _gameModel;
        }

        public function set gameModel(gamemodel:GameModel):void {
            this._gameModel = gamemodel;
        }

        private var cp:ConnectionPanel = new ConnectionPanel();

//        public function init(gameModel:GameModel):void {
//            this._gameModel = gameModel;
//        }

        public function MainPanel() {
            mainpanel = this;
            super();
            cp.x = 0;
            cp.y = 0;
            this.addChild(cp);
        }

        public function connected():void {
            dispatchEvent(new Event(Event.CONNECT));
        }

        public function setUpMainGamePanel(mainGamePanel:MainGamePanel):void {
            this.removeAllChildren();
            this.mainGamePanel = mainGamePanel;
            mainGamePanel.x = 0;
            mainGamePanel.y = 0;
//			mainGamePanel.setStyle("horizontalCenter", 0);
//			mainGamePanel.setStyle("verticalCenter", 0);
            mainGamePanel.percentHeight = 100;
            mainGamePanel.percentWidth = 100;
            this.addChild(mainGamePanel);
        }


        public function setupMVC(model:GameModel, mainView:DGComponent, controller:GameController):void {
            mainGamePanel.setupMVC(model, mainView, controller);
        }

        public function setGamePanel(gamePanel:Canvas):void {
            mainGamePanel.setGamePanel(gamePanel);
        }

    }
}